package com.second.app.thread.线程基础.day03;

/**
 * @Author GYZ
 * @Date 2023/11/20
 * <pre>
 *    案例1: 对应HasSelfPrivateNum
 *    案例2：对应HasSelfPrivate1Num
 * </pre>
 */
public class Main {

    public static void main(String[] args) {

        //案例1
//        class Thread001 extends Thread {
//            private HasSelfPrivateNum hasSelfPrivateNum;
//
//            public Thread001(HasSelfPrivateNum hasSelfPrivateNum) {
//                this.hasSelfPrivateNum = hasSelfPrivateNum;
//            }
//
//            @Override
//            public void run() {
//                hasSelfPrivateNum.addI("a");
//            }
//        }
//
//        class Thread002 extends Thread {
//            private HasSelfPrivateNum hasSelfPrivateNum;
//
//            public Thread002(HasSelfPrivateNum hasSelfPrivateNum) {
//                this.hasSelfPrivateNum = hasSelfPrivateNum;
//            }
//
//            @Override
//            public void run() {
//                hasSelfPrivateNum.addI("b");
//            }
//        }
//
//        HasSelfPrivateNum hasSelfPrivateNum = new HasSelfPrivateNum();
//
//        Thread001 thread001 = new Thread001(hasSelfPrivateNum);
//
//        thread001.start();
//
//        Thread002 thread002 = new Thread002(hasSelfPrivateNum);
//
//        thread002.start();
        class Thread001 extends Thread {
            private HasSelfPrivate1Num hasSelfPrivate1Num;

            public Thread001(HasSelfPrivate1Num hasSelfPrivate1Num) {
                this.hasSelfPrivate1Num = hasSelfPrivate1Num;
            }

            @Override
            public void run() {
                hasSelfPrivate1Num.addI("a");
            }
        }

        class Thread002 extends Thread {
            private HasSelfPrivate1Num hasSelfPrivate1Num;

            public Thread002(HasSelfPrivate1Num hasSelfPrivate1Num) {
                this.hasSelfPrivate1Num = hasSelfPrivate1Num;
            }

            @Override
            public void run() {
                hasSelfPrivate1Num.addI("b");
            }
        }

        HasSelfPrivate1Num hasSelfPrivate1Num = new HasSelfPrivate1Num();

        Thread001 thread001 = new Thread001(hasSelfPrivate1Num);

        thread001.start();

        Thread002 thread002 = new Thread002(hasSelfPrivate1Num);

        thread002.start();
    }
}
